package com.dhl.cloud.course.service;


import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dhl.cloud.common.util.DateUtils;
import com.dhl.cloud.course.dao.MyPlanMapper;
import com.dhl.cloud.course.entity.MyPlan;

@Service
public class MyPlanService {
	@Autowired
	private MyPlanMapper myPlanMapper;
 
	public List<MyPlan> getMyPlanList(String username) {
		return myPlanMapper.getMyPlanList(username);
	}
	
	public int deleteByPrimaryKey(Integer id) {
		return myPlanMapper.deleteByPrimaryKey(id);
	}
	
	public int insert(MyPlan c) {
		if (c.getId() != null)
		{
			MyPlan cc = myPlanMapper.selectByPrimaryKey(c.getId());
			cc.setDaytime(c.getDaytime());
			cc.setStarttime(c.getStarttime());
			cc.setEndtime(c.getEndtime());
			cc.setContent(c.getContent());
			cc.setModifytime(DateUtils.getDateTime());
			return myPlanMapper.updateByPrimaryKey(cc);
		}
		else
		{
			c.setCreatetime(DateUtils.getDateTime());
			return myPlanMapper.insert(c);
		}
		
	}
}
